<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            width: 100%;
            background: url(./img/login-background.jpg);
            background-size: cover;
        }

        main {
            margin: 100px auto;
            text-align: center;
            width: 400px;
            height: 300px;
            border-radius: 10px;
            background-color: aliceblue;
        }

        main h2 {
            height: 100px;
            line-height: 100px;
        }

        main footer {
            height: 200px;
        }

        main footer input,
        main footer button {
            box-sizing: border-box;
            border-radius: 5px;
            width: 80%;
            height: 40px;
            line-height: 40px;
            margin-bottom: 20px;
            outline: none;
            border: 1px solid rgb(197, 197, 197);
        }

        main footer input {
            padding-left: 20px;
        }

        main footer button {
            color: white;
            color: 20px;
            background-color: rgb(43, 140, 251);
        }
    </style>
</head>

<body>
    <main>
        <h2>后台登录系统</h2>
        <footer>
            <input type="text" placeholder="账号">
            <input type="password" placeholder="密码">
            <button>登录</button>
        </footer>
    </main>
</body>

</html>
<script src="./axios.min.js"></script>
<script>
    // 登录页面
    var inputs = document.querySelectorAll('input')
    var btn = document.querySelector('button')
    btn.onclick = () => {
        axios.post('/user/login', { phone: inputs[0].value, pass: inputs[1].value }).then((res) => {
            console.log(res.data);
            if (res.data.code == 200) {
                alert('登录成功');
                location.href = './index.html'
            } else {
                alert('登录失败')
            }
        })
    }

</script>